import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from '@/router/index.js'
import '@/assets/font/font.css'
import '@/assets/base.css'
import 'amfe-flexible'

const app = createApp(App)

app.use(createPinia())
app.use(router)

app.mount('#app')
// main.js 添加以下代码（放在 flexible 引入之后）
const MAX_DESKTOP_WIDTH = 768 // 超过768px按PC模式显示

function setRemWithThreshold() {
  const docEl = document.documentElement
  // const clientWidth = Math.min(docEl.clientWidth, MAX_DESKTOP_WIDTH)
  console.log(docEl.clientWidth)
  if (docEl.clientWidth > MAX_DESKTOP_WIDTH) {
    // 计算基准值（保持与 postcss 配置一致）
    const remBase = 37.5
    docEl.style.fontSize = `${remBase}px`
  }
}

// 初始化执行
setRemWithThreshold()
// 监听窗口变化
window.addEventListener('resize', setRemWithThreshold)
